define(['text!login/register.html'],
    function(viewTemplate) {
        return Piece.View.extend({
            id: 'login_text',
            events: {
                "click .evt_register": "doRegister",
                "click #location": "location",

            },
            render: function() {
                $(this.el).html(viewTemplate);

                Piece.View.prototype.render.call(this);
                return this;
            },
            onShow: function() {
                //write your business logic here :)
                $("#address").val("输入地理位置");
                var windowHeight = $(window).height();
                var elTop = $("#register").offset().top;
                var elHeight = windowHeight - elTop;

                console.info(elHeight);
                $("#register").css({
                    "height": elHeight
                });
                new iScroll($("#register")[0]);
            },

            location: function() {

                console.log("定位开始");


                cordova.exec(function(data) {


                    alert(data);
                    $("#address").val(data);



                }, function(err) {
                    alert("定位失败");

                    console.info("失败 ");
                }, "Location", "getlocation", []);
            },
            doRegister: function() {



                alert("注册成功!");
                this.container.navigateForResult('/login/menu', {
                    trigger: true
                }, 'login/logined', this.onGotResult);
            }
        }); //view define

    });